<?php

$x=0;
$y=array();
$allPersons = 0;

for($x=0; $x<8; $x++){
	$y[] = floor($x+2);
	$allPersons += $y[$x];
}

$destinations = array();

for($i=0; $i<$allPersons; $i++){
	$destinations[] = floor(rand(0,7));
}

$xml = "";
$xml .= "
<elevator>
	<settings>
		<numberOfElev>2</numberOfElev>
		<stepTime>1</stepTime>
		<size>5</size>
		<algorithm>0</algorithm>
	</settings>";


$r=0;
for($p=0; $p<8; $p++){
	for($d=0;$d<$y[$p];$d++){
		$xml .="
		<passenger>
			<start>{$p}</start>
			<end>{$destinations[$r]}</end>
		</passenger>";
		$r++;
	}
}

$xml .="
</elevator>";

$file = fopen("wnda.xml",'w')or die("cant open file");
fwrite($file,$xml);
fclose($file);


?>